﻿namespace PropertyExpression.ControllableQuery
{
    public interface IParam<out T>
    {
        ISqlParam<T> GetSqlParam(string parameterName);

        ISqlParam<T> GenerateSqlParam();
    }

    public interface ISqlParam<out T>
    {
        string ToSql();
    }

    public static class Param
    {
        public static string ToSql<T>(this IParam<T> it)
        {
            return it.GenerateSqlParam().ToSql();
        }

        public static string ToSql<T>(this IParam<T> it, string parameterName)
        {
            return it.GetSqlParam(parameterName).ToSql();
        }
    }
}